package interfaces.options;

import fileHandling.language.Lang;
import interfaces.GUISource;
import interfaces.menu.AbsMenu;
import interfaces.menu.options.ControlOptionsContent;
import interfaces.superWidgets.InterfaceButton;

import org.fenggui.event.ButtonPressedEvent;
import org.fenggui.event.IButtonPressedListener;

public class KeyOptionWidget extends OptionWidget {
	
	private InterfaceButton keyButton;
	private AbsMenu menu;
	private ControlOptionsContent optionsWindow;
	
	public KeyOptionWidget(String initValue, Lang description, ControlOptionsContent optionsWindow, AbsMenu menu) {
		super(description, initValue);
		this.menu = menu;
		this.optionsWindow = optionsWindow;
		
		keyButton = new InterfaceButton(initValue, GUISource.middleFont);
		keyButton.addButtonPressedListener(getButtonListener());
		addWidget(keyButton);
	}
	
	@Override
	public String getValue() {
		String value = keyButton.getText();
		return value;
	}
	
	public void changeKey(String key) { keyButton.setText(key); }
	
	private IButtonPressedListener getButtonListener() {
		return new IButtonPressedListener() {
			@Override
			public void buttonPressed(ButtonPressedEvent e) {
				OptionKeyWindow keyWindow = new OptionKeyWindow(getThis(), menu);
				menu.addWidget(keyWindow);
			}
		};
	}
	
	private KeyOptionWidget getThis() { return this; }
	
	public ControlOptionsContent getOptionsWindow() { return optionsWindow; }
	
	@Override
	public void setToHigh() {}
	
	@Override
	public void setToLow() {}
	
	@Override
	public void setToMedium() {}
	
	@Override
	public void changeValue(String value) {}
}